#include <stdio.h>
#include "base/abc/abc.h"
#include "base/main/main.h"
#include "miter.h"
#include "countmin.h"
#include "opt.h"

extern int Abc_Difference(char *file1, char *file2);

int main(int argc, char *argv[])
{	
	Abc_Start();
	abctime clk = Abc_Clock();
	Abc_Difference(argv[1],argv[2]);
	clk = Abc_Clock() - clk;
	
	printf(" time =%lld\n", clk );
	
	Abc_Stop();
	return 0;
}


extern int Abc_Difference(char *file1, char *file2)
{
	Abc_Ntk_t * pNtk1 = NULL, *pNtk2 = NULL, *pMiter = NULL, *pNtkRes = NULL, *pTemp = NULL;
	double rate = 0;
	
	//Abc_Start();
	pNtk1 = Abc_AigFromfile(file1, 0);
	pNtk2 = Abc_AigFromfile(file2, 0);
	//Io_WriteBlifLogic(pNtk1,"out.blif",0);
	pMiter = Abc_AigCombine2Miter(pNtk1, pNtk2);
	
	pNtkRes = Abc_NtkCollapse( pMiter, ABC_INFINITY, 0, 1, 0, 0, 0 );
	Abc_NtkDelete( pMiter );
	
	ErrorRate(pNtkRes,NULL,&rate);
	printf("%lf\n",rate);
	
	Abc_NtkDelete( pNtk1 );
	Abc_NtkDelete( pNtk2 );
	//Abc_Stop();
	return 0;
}



